Skip to content

fix(dart/templates): tolerant int deserialization in models; make \$s… #1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

sadji-zigadi
Copy link

What does this PR do?

  • Fixes Dart model deserialization for integer fields.
  • For Dart templates, parses ints as (map['$field'] as num?)?.toInt() instead of assigning raw values.
  • Special-cases "$sequence" to be nullable in generated models to tolerate missing values.

Why:

  • Some servers return "$sequence" as a string or omit it. Previous code caused String → int and Null → int runtime errors in generated SDKs.

Test Plan

  • Regenerated the Dart/Flutter SDK from this template.
  • Verified generated Document.fromMap contains:
    • $sequence: (map['\$sequence'] as num?)?.toInt(), (nullable)
    • Other required ints use ?? 0 default when applicable.
  • Ran:
    • dart format .
    • dart analyze
    • flutter test on generated SDK
  • Manual check: Created documents and listed documents with/without "$sequence" and with "$sequence": "3"; confirmed no crashes and correct values.

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

Yes.

@istornz
Copy link

istornz commented Aug 11, 2025

If I understand well, It's because the new $sequence field is related to the new atomic numeric operations but it's not currently released for self-hosted.
In that case, the latest version of the lib is working for all users with Appwrite cloud (atomic numeric operations deployed) but not for all self hosted user using the latest 1.7.4 Appwrite version (not including atomic numeric operations for now).

Is it the case @stnguyen90 ? If yes, do you have any ETA for a new self-hosted release?
Thanks :)

@LevenLeD
Copy link

I had the same issue on my end after upgrading my instance...

@istornz
Copy link

istornz commented Aug 11, 2025

Is this PR maybe related? appwrite/appwrite#10270

@stnguyen90
Copy link
Contributor

@sadji-zigadi , thanks for creating this PR! 🙏🏼 Unfortunately, this is not the direction we wish to take. As mentioned in our contributing guide, please make sure you are assigned to an issue before working on it to avoid wasted effort.

@stnguyen90 stnguyen90 closed this Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants